
package com.nikmesoft.android.alwaysontime.adapters;

import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.nikmesoft.android.alwaysontime.R;
import com.nikmesoft.android.alwaysontime.models.SmsMainItem;

public class SmsSentAdapter extends ArrayAdapter<SmsMainItem>
{	private int resourceID;

	public SmsSentAdapter(Context context, int resourceID, List<SmsMainItem> objects)
	{	super(context, resourceID, objects);
		this.resourceID = resourceID;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{	SmsMainItem item = getItem(position);
		View row = convertView;
		if (row == null)
		{	LayoutInflater inflater;
			inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			row = inflater.inflate(this.resourceID, null);
		}
		
		ImageView img = (ImageView) row.findViewById(R.id.smsMainImgView);
		TextView tvContent = (TextView) row.findViewById(R.id.sms_tvContent);
		TextView tvPhone = (TextView) row.findViewById(R.id.sms_tvPhone);
		TextView tvType = (TextView) row.findViewById(R.id.sms_tvType);
		TextView tvDate = (TextView) row.findViewById(R.id.sms_tvDate);
		/*
		tvContent.setText(item.getContent());
		tvPhone.setText(item.getPhone());
		tvType.setText(item.getType());
		tvDate.setText(item.getDate());
		if( item.isOneTime()) img.setImageResource(R.drawable.ic_sms_item);
		else img.setImageResource(R.drawable.ic_sms_item_2);*/
		
		tvContent.setText( item.getContent());
		tvPhone.setText( item.getPhone());
		tvType.setText( item.isOneTime() ? "OneTime" : "Schedule");
		tvDate.setText( item.isOneTime() ? item.getDate() : "..........");
		img.setImageResource( R.drawable.ic_delete);
		return row;
	}

}
